<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title>登录</title>
    <link rel="stylesheet" href="__STATIC__/css/pintuer.css">
    <link rel="stylesheet" href="__STATIC__/css/admin.css">
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/js/pintuer.js"></script>
</head>
<body>
<form action="{:url('Login/repwd')}" method="post">

    <div class="form-group">
        <div class="field field-icon-right">
            <input type="text" value="{$Cookies.name|default=''}" id="name" class="input input-big" name="name" placeholder="登录账号" data-validate="required:请填写账号" />
            <span class="icon icon-user margin-small"></span>
        </div>
    </div>

    <div class="form-group">
        <div class="field">
            <input type="text"  class="input input-big" name="pwd"  placeholder="新密码:"/>
        </div>
    </div>

    <div class="form-group">
        <div class="field">
            <input type="text"  class="input input-big" name="email"  placeholder="邮箱地址"/>
            <br>
            <button id="send" type="button" value="1">发送邮件</button>

        </div>
    </div>

    <div class="form-group">
        <div class="field">
            <input type="text" id="code" class="input input-big" name="code"  placeholder="请输入验证码:"/>
        </div>
    </div>

    <div class="form-group">
        <div style="padding:30px;">
            <input type="submit" id="sub" class="button button-block bg-main text-big input-big" value="重置">
        </div>
    </div>
</form>
<script>
    $('#send').click(function () {
        var sendEmail = $("#send").val();
        $.ajax({
            "async":true,
            "url":"{:url('Login/sendEmail')}",
            "data":{"sendEmail":sendEmail},
            "type":"POST",
            "dataType":"json",
            "success":function($data) {

                if ($data['code']==0){
                    alert('网络波动,发送失败');
                }
                if ($data['code']==1){
                    alert('发送成功');
                }
            }
        });

        return false;
    });
    $('#code').blur(function () {
        var code = $("#code").val();
        $.ajax({
            "async":true,
            "url":"{:url('Login/emailCodeCheck')}",
            "data":{"code":code},
            "type":"POST",
            "dataType":"json",
            "success":function($data) {
                // console.log($data['code'])
                if ($data['code']==0){
                    alert('验证码错误');
                }
                if ($data['code']==1){
                    alert('验证码正确');
                }
                if ($data['code']==3){
                    alert('没有发送邮件,请先发送邮件');
                }
            }
        });
    });
</script>
</body>
</html>